package cn.lili.controller.channel;

import cn.lili.common.aop.annotation.DemoSite;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.channel.entity.Channel;
import cn.lili.modules.channel.service.ChannelService;
import cn.lili.modules.permission.entity.vo.AdminUserVO;
import cn.lili.modules.permission.service.AdminUserService;
import cn.lili.mybatis.util.PageUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p></p>
 * @since 2023/4/8 17:29
 */
@RestController
@Api(tags = "管理端,渠道接口")
@RequestMapping("/manager/channel")
public class ChannelController {

	@Autowired
	private ChannelService channelService;

	@Autowired
	private AdminUserService adminUserService;

	@PostMapping(value = "/add")
	@ApiOperation(value = "添加/更新渠道")
	public ResultMessage<Channel> saveOrUpdateChannel(Channel channel){
		channel.setId(null);
		channelService.save(channel);
		return ResultUtil.data(channel);
	}

	@GetMapping(value = "/list")
	@ApiOperation(value = "添加/更新渠道")
	public ResultMessage<IPage<Channel>> channelList(PageVO pageVo){
		IPage<Channel> page = channelService.channelList(PageUtil.initPage(pageVo), new QueryWrapper<>());
		return ResultUtil.data(page);
	}
}
